package com.yuanlrc.base.dao.admin;


import com.yuanlrc.base.entity.admin.Clazz;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;


/**
 * 班级列表数据处理层
 *
 */
@Repository
public interface ClazzDao  extends JpaRepository<Clazz,Long> {

    /**
     * 根据班级id查询
     * @param id
     * @return
     */
    @Query("select c from Clazz c where id = :id")
    public Clazz find(@Param("id")Long id);


    /**
     * 通过学院id和班级外键相绑定去查找对应的班级列表
     * @param id 学院的外键id
     * @return
     */
    @Query(value = "select * from ylrc_clazz where faculties_id =:id",nativeQuery = true)
    public List<Clazz> findClazzByFaculties(@Param("id") Long id);

    /**
     * 按照班级编号查找
     * @param num
     * @return
     */
    public Clazz findByNum(String num);

    /**
     * 按照班级名查找
     * @param name
     * @return
     */
    public Clazz findByName(String name);



}
